#!/usr/bin/env bash

BAR_ICON=""
ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png

while true; do
    count=$(dnf check-update | wc -l)
    count=$((count-2))
    if hash notify-send &>/dev/null; then
        if [[ $count -gt 50 ]]; then
            notify-send -u critical -i $ICON \
                        "You really need to update soon!!" "$count New package updates"
        elif [[ $count -gt 25 ]]; then
            notify-send -u normal -i $ICON \
                        "You should update soon" "$count New package updates"
        elif [[ $count -gt 2 ]]; then
            notify-send -u low -i $ICON \
                        "$count New package updates"
        fi
    fi

    while [[ $count -gt 0 ]]; do
        echo " $count"
        #if [[ $count -eq 1 ]]; then
            #echo "#U:$count"
        #elif [[ $count -gt 1 ]]; then
            #echo "$count Updates"
        #fi
        sleep 14400
        #sleep 8
        count=$(dnf check-update | wc -l)
        count=$((count-2))
    done

    while [[ $count -eq 0 ]]; do
        echo $BAR_ICON
        sleep 14400
        #sleep 1200
        count=$(dnf check-update | wc -l)
        count=$((count-2))
    done
done

